#include "ProgressBar.h"

void download(double total, void (*f)(double,double))
{
    double speed[10]={1.1,2.0,0.1,0,3.1,0.5,0.9,5,0.01,0.25};
    int r = rand()%10;
    int part = 0;
    printf("下载总量为：%0.2lf MB\n",total);
    while(part < total)
    {
        part += speed[r];
        if(part > total)
            part = total;
        f(part,total);
        r = rand()%10;
        usleep(50000);
    }
    printf("\n下载完成\n");
}

int main()
{
    srand((unsigned int)time(NULL));
    download(1000,RefreshProgressBar);       
    return 0;
}
